]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowManager: Add shortcuts to open new window of nth pinned app
authorLeleat <atule@pm.me>
Tue, 4 May 2021 10:58:00 +0000 (12:58 +0200)
committerMarge Bot <marge-bot@gnome.org>
Sun, 24 Dec 2023 10:56:09 +0000 (10:56 +0000)
Add new shortcuts to open a new instance of an app by pressing
Super + Ctrl + Number. This is analogous to ctrl-activating
(LMB/Enter) an app icon.

Close https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4129

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1829>

data/50-gnome-shell-launchers.xml
data/org.gnome.shell.gschema.xml.in
js/ui/windowManager.js

index 4a69770c24b9399d2567509c91422c631e73bc8b..1d8b276dab088c18119080f2ba00f3070a485267 100644 (file)
                       description="Activate pinned app 9"
                       hidden="true"/>
 
+       <KeyListEntry name="open-new-window-application-1"
+                      description="Open new window of pinned app 1"
+                      hidden="true"/>
+
+       <KeyListEntry name="open-new-window-application-2"
+                      description="Open new window of pinned app 2"
+                      hidden="true"/>
+
+       <KeyListEntry name="open-new-window-application-3"
+                      description="Open new window of pinned app 3"
+                      hidden="true"/>
+
+       <KeyListEntry name="open-new-window-application-4"
+                      description="Open new window of pinned app 4"
+                      hidden="true"/>
+
+       <KeyListEntry name="open-new-window-application-5"
+                      description="Open new window of pinned app 5"
+                      hidden="true"/>
+
+       <KeyListEntry name="open-new-window-application-6"
+                      description="Open new window of pinned app 6"
+                      hidden="true"/>
+
+       <KeyListEntry name="open-new-window-application-7"
+                      description="Open new window of pinned app 7"
+                      hidden="true"/>
+
+       <KeyListEntry name="open-new-window-application-8"
+                      description="Open new window of pinned app 8"
+                      hidden="true"/>
+
+       <KeyListEntry name="open-new-window-application-9"
+                      description="Open new window of pinned app 9"
+                      hidden="true"/>
+
 </KeyListEntries>
 
index d77a7f716d8e265f094bc3a99feea1573cdd6a9f..d90a1f61c90a217bee1597ee8f74ec98ac8b8b19 100644 (file)
       <default>["&lt;Super&gt;9"]</default>
       <summary>Switch to application 9</summary>
     </key>
+    <key name="open-new-window-application-1" type="as">
+      <default>["&lt;Super&gt;&lt;Control&gt;1"]</default>
+      <summary>Open a new instance of application 1</summary>
+    </key>
+    <key name="open-new-window-application-2" type="as">
+      <default>["&lt;Super&gt;&lt;Control&gt;2"]</default>
+      <summary>Open a new instance of application 2</summary>
+    </key>
+    <key name="open-new-window-application-3" type="as">
+      <default>["&lt;Super&gt;&lt;Control&gt;3"]</default>
+      <summary>Open a new instance of application 3</summary>
+    </key>
+    <key name="open-new-window-application-4" type="as">
+      <default>["&lt;Super&gt;&lt;Control&gt;4"]</default>
+      <summary>Open a new instance of application 4</summary>
+    </key>
+    <key name="open-new-window-application-5" type="as">
+      <default>["&lt;Super&gt;&lt;Control&gt;5"]</default>
+      <summary>Open a new instance of application 5</summary>
+    </key>
+    <key name="open-new-window-application-6" type="as">
+      <default>["&lt;Super&gt;&lt;Control&gt;6"]</default>
+      <summary>Open a new instance of application 6</summary>
+    </key>
+    <key name="open-new-window-application-7" type="as">
+      <default>["&lt;Super&gt;&lt;Control&gt;7"]</default>
+      <summary>Open a new instance of application 7</summary>
+    </key>
+    <key name="open-new-window-application-8" type="as">
+      <default>["&lt;Super&gt;&lt;Control&gt;8"]</default>
+      <summary>Open a new instance of application 8</summary>
+    </key>
+    <key name="open-new-window-application-9" type="as">
+      <default>["&lt;Super&gt;&lt;Control&gt;9"]</default>
+      <summary>Open a new instance of application 9</summary>
+    </key>
     <key name="show-screenshot-ui" type="as">
       <default>["Print"]</default>
       <summary>Take a screenshot interactively</summary>
index 0cb0788de708d30e2f43c94901aeb8855a1cdca1..6af225f1462bee950f9b4f101b2f17f64017f96e 100644 (file)
@@ -819,6 +819,60 @@ export class WindowManager {
             Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
             this._switchToApplication.bind(this));
 
+        this.addKeybinding('open-new-window-application-1',
+            new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
+            this._openNewApplicationWindow.bind(this));
+
+        this.addKeybinding('open-new-window-application-2',
+            new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
+            this._openNewApplicationWindow.bind(this));
+
+        this.addKeybinding('open-new-window-application-3',
+            new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
+            this._openNewApplicationWindow.bind(this));
+
+        this.addKeybinding('open-new-window-application-4',
+            new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
+            this._openNewApplicationWindow.bind(this));
+
+        this.addKeybinding('open-new-window-application-5',
+            new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
+            this._openNewApplicationWindow.bind(this));
+
+        this.addKeybinding('open-new-window-application-6',
+            new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
+            this._openNewApplicationWindow.bind(this));
+
+        this.addKeybinding('open-new-window-application-7',
+            new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
+            this._openNewApplicationWindow.bind(this));
+
+        this.addKeybinding('open-new-window-application-8',
+            new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
+            this._openNewApplicationWindow.bind(this));
+
+        this.addKeybinding('open-new-window-application-9',
+            new Gio.Settings({schema_id: SHELL_KEYBINDINGS_SCHEMA}),
+            Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
+            Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
+            this._openNewApplicationWindow.bind(this));
+
         global.stage.connect('scroll-event', (stage, event) => {
             const allowedModes = Shell.ActionMode.NORMAL;
             if ((allowedModes & Main.actionMode) === 0)
@@ -1656,19 +1710,30 @@ export class WindowManager {
         return Main.sessionMode.hasOverview;
     }
 
-    _switchToApplication(display, window, binding) {
+    _getNthFavoriteApp(n) {
         if (!this._allowFavoriteShortcuts())
-            return;
+            return null;
 
-        let [, , , target] = binding.get_name().split('-');
-        let apps = AppFavorites.getAppFavorites().getFavorites();
-        let app = apps[target - 1];
+        const apps = AppFavorites.getAppFavorites().getFavorites();
+        return apps[n];
+    }
+
+    _switchToApplication(display, window, binding) {
+        const [, , , target] = binding.get_name().split('-');
+        const app = this._getNthFavoriteApp(target - 1);
         if (app) {
             Main.overview.hide();
             app.activate();
         }
     }
 
+    _openNewApplicationWindow(display, window, binding) {
+        const [, , , , target] = binding.get_name().split('-');
+        const app = this._getNthFavoriteApp(target - 1);
+        if (app)
+            app.open_new_window(-1);
+    }
+
     _toggleCalendar() {
         Main.panel.toggleCalendar();
     }